﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true"
    Inherits="Admin_ConstituentManagement" CodeBehind="ConstituentManagement.aspx.cs" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajt" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphHead" runat="Server">    
    <script src="../Scripts/jquery.maskedinput-1.2.2.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $("#<%=txtPhone.ClientID%>").mask("(999) 999-9999");
            $("#<%=txtZip.ClientID%>").mask("99999-9999");
        });
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphTitle" runat="Server">
    Constituents
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphBody" runat="Server">
    <asp:ScriptManager ID="scriptManager1" runat="server" />
        <asp:LinkButton ID="btnNewConstituent" Text="Create a constituent" OnClick="btnNewConstituent_Click"
        runat="server" />
    <br />
    <br />
    <asp:GridView ID="grvConstituents" runat="server" AutoGenerateColumns="false" OnRowDeleting="DeleteRecord"
        DataKeyNames="ID" OnRowDataBound="RowDataBound">
        <Columns>
            <asp:TemplateField HeaderText="Name">
                <ItemTemplate>
                    <a href='<%# DataBinder.Eval(Container.DataItem, "ID", "ConstituentInformation.aspx?ID={0}") %>'>
                        <%# DataBinder.Eval(Container.DataItem, "Name")%>
                    </a>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Address">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "Address.AddressBlock")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="City">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "Address.City")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="State">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "Address.State.Abbreviation")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Zip">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "Address.PostCode")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Phone">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "Phone.NumberWithExtension")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Email">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "EmailAddress.EmailAddress")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("ID") %>'
                        CommandName="Delete" Text="Delete" ForeColor="Black" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <ajt:ModalPopupExtender ID="modalNewConstituent" runat="server" CancelControlID="btnCancel"
        TargetControlID="btnNewConstituent" PopupControlID="pnlNewGuest" PopupDragHandleControlID="PopupHeader"
        Drag="true" BehaviorID="ShowModal" BackgroundCssClass="modalBackground">
    </ajt:ModalPopupExtender>
    <asp:Panel ID="pnlNewGuest" runat="server">
        <div id="modal">
            <div id="modalBody">
                <table width="600" border="0">
                    <tr>
                        <td align="left" width="300" valign="top">
                            <table>
                                <tr>
                                    <td colspan="2">
                                        <asp:UpdatePanel ID="updatePanel" runat="server">
                                            <ContentTemplate>
                                                <asp:CheckBox ID="chkIsOrganization" runat="server" Text="Is an organization?" OnCheckedChanged="chkIsOrganization_CheckedChanged"
                                                    AutoPostBack="true" Checked="true" />
                                                <asp:Panel ID="pnlOrganization" runat="server" Visible="true">
                                                    <table>
                                                        <tr>
                                                            <td>
                                                                Name:
                                                            </td>
                                                            <td>
                                                                <asp:TextBox ID="txtOrganizationName" runat="server" MaxLength="100" />
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </asp:Panel>
                                                <asp:Panel ID="pnlConstituent" runat="server" Visible="false">
                                                    <table>
                                                        <tr>
                                                            <td>
                                                                First name:
                                                            </td>
                                                            <td>
                                                                <asp:TextBox ID="txtFirstName" runat="server" MaxLength="100" />
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                Last name:
                                                            </td>
                                                            <td>
                                                                <asp:TextBox ID="txtLastName" runat="server" MaxLength="100" />
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </asp:Panel>
                                            </ContentTemplate>
                                            <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="chkIsOrganization" />
                                            </Triggers>
                                        </asp:UpdatePanel>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <hr />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Type:
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlPhoneType" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Phone:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtPhone" runat="server" MaxLength="20" Columns="11" />
                                        ext.
                                        <asp:TextBox ID="txtExtension" runat="server" MaxLength="6" Columns="3" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <hr />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Type:
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlEmailType" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Email:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtEmail" runat="server" MaxLength="100" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td align="left" width="300" valign="top">
                            <table>
                                <tr>
                                    <td>
                                        Type:
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlAddressType" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td valign="top">
                                        Address:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine" MaxLength="1000" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        City:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtCity" runat="server" MaxLength="50" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        State:
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlState" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Zip code:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtZip" runat="server" MaxLength="12" Columns="8" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Country:
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlCountry" runat="server" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
                        </td>
                        <td>
                            <asp:Button ID="btnSubmit" runat="server" Text="Create" CausesValidation="false"
                                OnClick="btnSubmit_Click" OnClientClick="showModal();" />                            
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </asp:Panel>
</asp:Content>
